module.exports = {
  apps: [
     {
      name: 'flask-api',
      cwd: '/home/bupt/dify-plus/api',
      script: '/home/bupt/miniconda3/envs/dify-plus/bin/gunicorn',
      args: 'app:app --bind 0.0.0.0:5001 --workers 8 --threads 19 --worker-class gevent --timeout 200 --keep-alive 65 --max-requests 1000 --max-requests-jitter 50 --worker-connections 1000',
      interpreter: "/home/bupt/miniconda3/envs/dify-plus/bin/python",
      autorestart: true,
      watch: false,
      max_memory_restart: '12G',
    },
    {
      name: 'celery-worker',
      cwd: '/home/bupt/dify-plus/api',
      script: '/home/bupt/miniconda3/envs/dify-plus/bin/python',
      args: '-m celery -A app.celery worker -P gevent -c 31 -Q dataset,generation,mail,ops_trace,extend_high,extend_low --loglevel INFO',
      autorestart: true,
      watch: false,
      interpreter: 'none',  // 明确禁用 Node.js 解释器
      max_memory_restart: '4G',
      error_file: 'logs/celery_error.log',
      out_file: 'logs/celery_output.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss'
    },
    {
      name: 'celery-beat',
      cwd: '/home/bupt/dify-plus/api',
      script: '/home/bupt/miniconda3/envs/dify-plus/bin/python',
      args: '-m celery -A app.celery beat --loglevel INFO',
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      error_file: 'logs/celery_beat_error.log',
      out_file: 'logs/celery_beat_output.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss'
    },
    {
      name: 'web-frontend',
      cwd: '/home/bupt/dify-plus/web',
      script: 'npm',
      args: 'run start',
      autorestart: true,
      watch: false,
      max_memory_restart: '2G',
      error_file: 'logs/web_error.log',
      out_file: 'logs/web_output.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
      env: {
        PORT: 3000,
        HOST: '0.0.0.0'
      }
    },
    {
      name: 'admin-web',
      cwd: '/home/bupt/dify-plus/admin/web',
      script: 'npm',
      args: 'run serve',
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      error_file: 'logs/admin_web_error.log',
      out_file: 'logs/admin_web_output.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss'
    },
    {
      name: 'admin-server',
      cwd: '/home/bupt/dify-plus/admin/server',
      script: 'go',
      args: 'run main.go',
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      error_file: 'logs/admin_server_error.log',
      out_file: 'logs/admin_server_output.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss'
    }
  ]
};